package com.castle.fortress.admin.form.dto;

import com.castle.fortress.admin.utils.BizCommonUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * 表字段模型对象
 * @author castle
 */
@Data
@ApiModel(value = "表字段模型对象", description = "表字段模型对象")
	public class ColModelDto implements Serializable {
	private static final long serialVersionUID = 1L;
	@JsonSerialize(using = ToStringSerializer.class)
	@ApiModelProperty(value = "主键ID")
	@JsonProperty("id")
	private Long id;
	@JsonSerialize(using = ToStringSerializer.class)
	@ApiModelProperty(value = "主键ID")
	@JsonProperty("formId")
	private Long formId;
	@ApiModelProperty(value = "字段名")
	@JsonProperty("colName")
	private String colName;
	@ApiModelProperty(value = "字段类型")
	@JsonProperty("colType")
	private String colType;
	@ApiModelProperty(value = "字段说明")
	@JsonProperty("colComment")
	private String colComment;
	@ApiModelProperty(value = "字段标签")
	@JsonProperty("colTag")
	private String colTag;
	@Override
	public boolean equals(Object obj) {
		if(this == obj){
			return true;//地址相等
		}
		if(obj == null){
			return false;//非空性：对于任意非空引用x，x.equals(null)应该返回false。
		}
		if(obj instanceof ColModelDto){
			ColModelDto other = (ColModelDto) obj;
			//需要比较的字段相等，则这两个对象相等
			if(BizCommonUtil.equalsStr(this.colName, other.colName)
							&& BizCommonUtil.equalsStr(this.colType, other.colType)
							&& BizCommonUtil.equalsStr(this.colComment, other.colComment)
							&& BizCommonUtil.equalsStr(this.colTag, other.colTag)){
				return true;
			}
		}
		return false;
	}
}
